package test;

import java.util.ArrayList;
import java.util.List;

import org.keyroy.util.tag.SimpleXmlObject;
import org.keyroy.util.tag.Tag;

public class T2_SimpleXmlObject {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Student student = new Student();
		student.info = new Info();
		student.info.text = "hello.simple.xml.object";
		for (int i = 0; i < 3; i++) {
			Work work = new Work();
			work.ID = i;
			work.name = "work" + i;
			student.works.add(work);
		}

		String xml = new Tag(student).toFormateString();
		System.out.println(xml);

		student = (Student) new Tag(xml).toObject(Student.class);

		xml = new Tag(student).toFormateString();
		System.out.println(xml);
	}

	public static class Info extends SimpleXmlObject {
		public String text;
	}

	public static class Work extends SimpleXmlObject {
		public int ID;
		public String name;
	}

	public static class Student extends SimpleXmlObject {
		public Info info;
		public List<Work> works = new ArrayList<T2_SimpleXmlObject.Work>();

	}

}
